package hips.gui.images;

import hips.images.ImagePartitionable;
import javax.swing.JOptionPane;

public class Image {

    public static hips.images.Image getOutputImage(ImagePartitionable input) {
        if (input.getSlices() == 1) {
            return input.newImageRGB();
        }
        if (input instanceof hips.images.gray8.ImageGray8) {
            if (input.getSlices() == 3) {
                Object[] options = {"Yes", "No"};
                int n = JOptionPane.showOptionDialog(null,
                        "Would you like to see the partition as one output RGB image?",
                        "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
                if (n == 0) {
                    return new Image3(input.getWidth(), input.getHeight(), "");
                }
            }
            if (input.getSlices() == 4) {
                Object[] options = {"Yes", "No"};
                int n = JOptionPane.showOptionDialog(null,
                        "Would you like to see the partition as two output RGB images? (RGB + IRGB)",
                        "Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
                if (n == 0) {
                    return new Image4(input.getWidth(), input.getHeight(), "");
                }
            }
        }
        return input.newImageRGB();
    }
}
